<template>
  <div>
    <h2>
      <p>“绘画”值得学的课</p>
      <a href="javascript:;">更多 &gt;</a>
    </h2>

    <div class="banbox">
      <div class="classbanner">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="(item, i) in classes" :key="i">
           <router-link :to="'/details/'+item.id">
              <div class="imgbox"><img :src="item.img" alt="" /></div>
            <p class="title">{{ item.desc }}</p>
            <p class="price">￥{{ item.prices }}</p>
           </router-link>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/css/swiper.css";
import { getClass } from "../../api/Recommend";
export default {
  data() {
    return {
      classes: [],
    };
  },
  mounted() {
    getClass()
      .then((res) => {
        this.classes = res.data;
      })
      .then(() => {
        var swiper = new Swiper(".classbanner", {
          slidesPerView: "auto",
          spaceBetween: 10,
          freeMode: true,
        });
      });
  },
};
</script>

<style scoped>
h2 {
  height: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
h2 p {
  font-size: 0.3rem;
}
h2 a {
  font-size: 0.28rem;
  font-weight: normal;
}
.imgbox{
  display: flex;
  justify-content: center;
  align-items: center;
  height: 1.7rem;
}
img {
  width: 2.8rem;
  height: 1.48rem;
}
.banbox {
  width: 100%;
  height: 3.46rem;
  overflow: hidden;
}

.classbanner {
  width: 100%;
  height: 100%;
}

.swiper-slide {
  font-size: 18px;
  background: #fff;
  height: 100% !important;
  width: 3rem !important;
  padding: 0 0.1rem;  
}
.title{
  font-size: 0.26rem;
  line-height: 0.38rem;
}
.price{
  font-size: 0.26rem;
  color: #ee6848;
  line-height: 0.38rem;
}
</style>
